/**
 * Promise化小程序接口
 */
class Wechat {
  /**
   * 登陆
   * @return {Promise} 
   */
  static login() {
    return new Promise((resolve, reject) => wx.login({ success: resolve, fail: reject }));
  };

  /**
   * 获取用户信息
   * @return {Promise} 
   */
  static getUserInfo() {
    return new Promise((resolve, reject) => wx.getUserInfo({ success: resolve, fail: reject }));
  };

  static downloadFile(url) {
    return new Promise((resolve, reject) => wx.downloadFile({ url: url, success: resolve, fail: reject }));
  };

  static saveFile(tempFilePath) {
    return new Promise((resolve, reject) => wx.saveFile({ tempFilePath: tempFilePath, success: resolve, fail: reject }));
  };

  static saveImageToPhotosAlbum(tempFilePath) {
    return new Promise((resolve, reject) => wx.saveImageToPhotosAlbum({ filePath: tempFilePath, success: resolve, fail: reject }));
  };


};

module.exports = Wechat;